<?php 
    include_once '../header.inc';
    require_once '../conn.php';
?>

<div class="apmd bbcnavgray"><a href="../index.php">首页</a>&gt;<a href="../contactlist.php">联系人列表</a>&gt;添加联系人</div>

<div class="apmd">
    <form action="add_contact" method="POST">
        <p class="aclb">添加联系人(第3/3步)</p>
        <p>填写联系人信息</p>
        <div>
            <?php
                $cid = empty($_POST['txtcid']) ? $_GET['cid'] : $_POST['txtcid'];
                $sid = empty($_POST['slidentity']) ? $_GET['sid'] : $_POST['slidentity'];
                
                $sql = "select gid, gname from cc_group where sid ='".$sid."'";
                $res = $ms_cc_pdo->select($sql);
                $row = $res['result'];
                if(count($row) > 0 ){
                //todo: 此处需要确定需求，是否需要默认分组
            ?>
            <select id="slgroup" name="slgroup">
                <?php
                    foreach ($row as $key =>$item) {
                        echo '<option value='.$item['gid'].'>'.$item['gname'].'</option>';
                    }
                ?>
            </select>
            <?php
                }
            ?>
            <span><a href="../group/group_add.php?ref=acg&cid=<?php echo $cid; ?>&sid=<?php echo $sid; ?>">新建分组</a></span>
            <p>
            <?php
                if(count($row) > 0 ){
                    echo '<span><input type="hidden" name="txtcid" value='.$_GET['cid'] .' /></span>';
                    echo '<span><input type="submit" id="btn_add_group" name="btn_add_group" value="下一步" /></span>';
                }
            ?>
            <span><a href="../contact/contact_add.php?cid=<?php echo $cid; ?>">上一步</a></span>
            </p>
        </div>
    </form>
</div>

<?php include_once '../footer.inc'; ?>
